$(function() {


	var initFn=function() {
		bindEvt();
	};


	var bindEvt = function() {
		$('#tel_num').on('input',onTelnumChange);
		$('.get_verify').on('tap',onVerifyTap);
	};

	var onTelnumChange = function() {
		var reg = /^1[34578]\d{9}$/;
		
		this.value=this.value.replace(/\D/g,'');
		if(this.value.length==11) {
			if( reg.test(this.value) ) {
				$('.get_verify').addClass('on');
			}else {
				$('.get_verify').removeClass('on');
			}
		}else {
			$('.get_verify').removeClass('on');
		}
	};

	var onVerifyTap = function() {
		var tag=$(this).hasClass('on');
		var vcode=$('#very_code').val();
		if(!tag) {
			return;
		}else {
			// renderVery();
		}
	};






	function getsVerify(item) {
	    var http_url = serveUrl();
	    var ajax_url = http_url + '/api/push/sendverifyuser';
	    var mobile = $("#tel_num").val();
	    // 对发送的数据进行处理
	    var str = $.md5("areaCode=86&mobile=" + mobile + "&sendMode=" + item);
	    var sign_s = $.md5(str + '654eva321');
	    var data = JSON.stringify({sendMode: item, mobile: mobile, areaCode: 86, sign: sign_s});
	    $.ajax({
	        type: 'POST',
	        url: ajax_url,
	        contentType: "application/json;charset=UTF-8",
	        data: data,
	        error: function (error) {
	            console.log(error);
	        },
	        success: function (data) {
	            if(data.code == '0'){
	                layer.open({
	                    content: item === 'sms'?'验证码已发送':'验证码将以电话形式通知您，请注意查收'
	                    ,skin: 'msg'
	                    ,time: 2 //2秒后自动关闭
	                });
	            }
	        }
	    });
	}


	function cellNumber(num) {
        var $p = $(num);
        var $inputmane = $p.find("input");
        var thisval = $inputmane.val();
        var reg = /^0?1[3|7|4|5|8][0-9]\d{8}$/;
        if (!reg.test(thisval)) {
            document.getElementById("hidden").value = "";
            $(".layer_tel").show()
            setTimeout(function () {
                $(".layer_tel").hide()
            }, 2000)
        } else {
            document.getElementById("hidden").value = 1;
        }
    }










	initFn();
})